home *** CD-ROM | disk | FTP | other *** search
/ The Games Machine 76 / XENIATGM66.iso / Indiana Jones / Indiana Jones.exe / RESOURCE / PREVIEW.GOB / cog_actor_lavaboss.cog < prev    next >
Text File  |  1999-11-15  |  11KB  |  434 lines

  1. # Jones 3D Cog Script
  2. #
  3. # actor_LavaBoss.cog
  4. #
  5. # [MDR]
  6. #
  7. # (C) 1999 LucasArts Entertainment Company LLC. All Rights Reserved
  8. #
  9. #    #####  Notes  #####
  10. #    n_AICustomMode usuage:
  11. #        0x02 - FIRING_LAVA
  12. #
  13. # ===================================================================
  14.  
  15. symbols
  16.  
  17. message        initialized
  18. message        aievent
  19. message        fire
  20. message        timer
  21. message        pulse
  22. message     removed
  23. message     damaged
  24. message        callback
  25. message        user0
  26. message        user1
  27.  
  28. # ************************** TEMPLATES *************************
  29. template    tpl_PrimaryWeapon=+lavahit_lg        local
  30. template    tpl_AltWeapon=+nopainhit            local
  31. template    tpl_LavaGuy=lava_guy                local
  32.  
  33. template    tpl_sparks00=lbossSparksMD            local        # Med sparks
  34. template    tpl_sparks01=lbossSparksLG            local        # Large sparks
  35. template    tpl_sparks02=lavasparks                local        # generic lava sparks
  36.  
  37. template    tpl_plume=lbossFntn                    local
  38. template    tpl_lavaShrp0=lavashrapa            local
  39. template    tpl_lavaShrp1=lavashrapb            local
  40. template    tpl_lavaShrp2=lavashrapc            local
  41.  
  42. # ************************** AI CLASSES ************************
  43. ai            ai_mad=lavaboss_mad.ai                local
  44.  
  45. # ************************** WEAPON HANDLERS *******************
  46. int            n_NumLavaGuys=0                        local
  47. int            n_MaxLavaShot=3                        local
  48. int            n_shotCount                            local
  49. thing        t_LavaGuy                            local
  50. vector        vec_altOffset                        local
  51.  
  52. # ************************** SPECIAL FX ************************
  53. int            n_joint00                            local
  54. int            n_joint01                            local
  55. int            n_joint02                            local
  56. int            n_joint03                            local
  57. int            n_joint04                            local
  58.  
  59. vector        vec_velDebris                        local
  60.  
  61. # ************************** MISC LOCAL VARS *******************
  62. thing        t_Player                            local
  63. thing        t_boss                                local
  64. thing        t_sender                            local
  65. thing        t_obj                                local
  66. thing        t_objSpark                            local
  67. thing        t_posGhost=-1                        local
  68.  
  69. int            n_AICustomMode=0                    local
  70. int            FIRING_LAVA=1                        local
  71.  
  72. int            n_eventType                            local
  73. int            n_param                                local
  74.  
  75. int            n_idx                                local
  76. flex        f_val                                local
  77. sector        sec_atNewPos                        local
  78. vector        vec_pos                                local
  79. vector        vec_dir                                local
  80. vector        vec_vel                                local
  81. vector        vec_rot                                local
  82.  
  83. # ************************** SUBROUTINES *******************
  84. flex        ShootLavaPlume                        local
  85. flex        ShootLavaDebris                        local
  86. flex        ShootLavaGuys                        local
  87.  
  88. end
  89.  
  90. # ===================================================================
  91.  
  92. code
  93.  
  94. # ...................................................................
  95. initialized:
  96.     t_boss        = GetSenderRef();
  97.  
  98.     AISetAllowedSurfaceType(t_boss, 0x200000);                # Allow walking on SITH_SURFACE_LAVA
  99.     SetActorFlags(t_boss, 0x20000);                            # Set AF_DELAYFIRE
  100.  
  101. #    SetPuppetModeFPS(t_boss, 0, 71, 20);                    # Slow down PUPPETADDIN_STAND2CRAWL
  102. #    SetPuppetModeFPS(t_boss, 0, 72, 20);                    # Slow down PUPPETADDIN_CRAWL2STAND
  103.  
  104.     n_joint00 = GetNodeByName(t_boss, "lbhead");
  105.     n_joint01 = GetNodeByName(t_boss, "lblarm");
  106.     n_joint02 = GetNodeByName(t_boss, "lbrarm");
  107.     n_joint03 = GetNodeByName(t_boss, "lbl4arm");
  108.     n_joint04 = GetNodeByName(t_boss, "lbr4arm");
  109.  
  110.     vec_velDebris = VectorSet(0, 0.7, 0.8);
  111.  
  112.     SetPulse(2.0);
  113.  
  114.     vec_altOffset = VectorSet(0.0, 0.25, 0.1);
  115.  
  116.     return;
  117.  
  118. # ...................................................................
  119. aievent:
  120.  
  121.     n_eventType    = GetParam(0);
  122.     n_param        = GetParam(2);
  123.     t_sender    = GetSenderRef();
  124.  
  125.     if ( t_sender != t_boss )
  126.         return;
  127.  
  128.     if (n_eventType == 0x10000)                                #---- EVENT_PREFIRE
  129.     {
  130.         if ( BITTEST(n_param, 0x0020) )                        #---- SITHAIUTIL_FIRE_ALT
  131.         {
  132.             if ( !BITTEST(n_AICustomMode, FIRING_LAVA) && (n_NumLavaGuys < 12) )
  133.             {
  134.                 SetActorWeapon(t_boss, tpl_AltWeapon);        # Swap to alternate weapon
  135.                 SetThingFireoffset(t_boss, vec_altOffset);
  136.             }
  137.             else
  138.             {
  139. #                DEBUGFLEX(n_NumLavaGuys, "Cant shoot lava guys, n_NumLavaGuys =");
  140.                 SetActorWeapon(t_boss, -1);                        # Disable alternate weapon
  141.             }
  142.         }
  143.     }
  144.     else if (n_eventType == 0x20000)                        #---- EVENT_POSTFIRE
  145.     {
  146.         SetActorWeapon(t_boss, tpl_PrimaryWeapon);                # Swap back to default weapon template
  147.         SetThingFireoffset(t_boss, '0 0 0');
  148.     }
  149.     else if (n_eventType == 0x04)                                #---- EVENT_TOUCHED
  150.     {                                                            # n_param == touched thing index
  151.         if ( GetThingType(n_param) == 10 )                            # Boss touched a SITH_THING_PLAYER
  152.         {
  153.             DamageThing(n_param, 1000, 0x200, t_boss);                # Inflict SITH_DAMAGE_LAVA
  154.         }
  155.     }
  156.     else if (BITTEST(n_eventType, 0x100e04))
  157.     {
  158.         ReturnEx(1);
  159.     }
  160.  
  161.     return;
  162.  
  163.  
  164. # ...................................................................
  165. fire:
  166.  
  167.     t_sender = GetSenderRef();
  168.     if ( t_sender != t_boss )
  169.         return;
  170.  
  171.     if ( IsModePlaying(t_boss, 68) > 0 )
  172.     {
  173.         call ShootLavaGuys;
  174.     }
  175.  
  176.     return;
  177.  
  178.  
  179. # ...................................................................
  180. pulse:
  181.  
  182.     t_sender    = GetSenderRef();
  183.  
  184.     if ( t_boss == -1 )
  185.     {
  186.         SetPulse(0);
  187.         return;
  188.     }
  189.  
  190.     if ( BITTEST(GetActorFlags(t_boss), 0x40000) )                # IMMOBILE == no sparks
  191.     {
  192.         return;
  193.     }
  194.  
  195.     if ( !BITTEST(GetThingFlags(t_boss), 0x80000) )
  196.     {
  197.         n_param = RandBetween(2, 5);
  198.  
  199.         for ( n_idx = 0; n_idx < n_param; n_idx = n_idx + 1)
  200.         {
  201.             vec_pos = GetThingJointPos(t_boss, n_joint00[RandBetween(0, 4)]);
  202.             CreateThingAtPos(tpl_sparks00, FindNewSectorFromThing(t_boss, vec_pos), vec_pos, '0 0 0');
  203.         }
  204.     }
  205.  
  206.     return;
  207.  
  208.  
  209. # ...................................................................
  210. timer:
  211.  
  212.     t_sender = GetSenderRef();
  213.     if ( (t_sender != t_boss) && (GetThingType(t_sender) == 2) )    # SITH_THING_ACTOR?
  214.     {
  215. #        DEBUGPRINT("Waking up lava dude");
  216.         AIClearCutsceneMode(t_sender);                                # Reactivate Lava guy
  217.     }
  218.  
  219.     return;
  220.  
  221.  
  222. # ...................................................................
  223. removed:
  224.  
  225.     t_sender = GetSenderRef();
  226.     if ( t_sender == t_boss )
  227.     {
  228.         t_boss = -1;
  229.     }
  230.     else if ( GetThingType(t_sender) == 2 )                            # SITH_THING_ACTOR?
  231.     {
  232. #        DEBUGPRINT("Lava Minion removed");
  233.         SetThingTimer(t_sender, 0);
  234.         n_NumLavaGuys = n_NumLavaGuys - 1;
  235.     }
  236.  
  237.     return;
  238.  
  239.  
  240. # ...................................................................
  241. callback:
  242.  
  243.     t_sender = GetSenderRef();
  244.     if ( t_sender == t_boss )
  245.     {
  246.         n_param = GetParam(1);
  247.         if ( n_param == 21 )                                    #*** Begin Submerging
  248.         {
  249.             StopSoundClass(t_boss, 2);                                # stop 'activated'
  250.         }
  251.         else if ( n_param == 22 )                                #*** End Submerging
  252.         {
  253.             PlaySoundClass(t_boss, 50);                                # play 'enterwater'
  254.  
  255.             call ShootLavaDebris;
  256.         }
  257.         else if ( n_param == 23 )                                #*** Begin Surfacing
  258.         {
  259.             PlaySoundClass(t_boss, 52);                                # play 'exitwater'
  260.  
  261.             call ShootLavaPlume;
  262.             call ShootLavaDebris;
  263.         }
  264.         else if ( n_param == 24 )                                #*** End Surfacing
  265.         {
  266.             PlaySoundClass(t_boss, 2);                                # play 'activated'
  267.         }
  268.     }
  269.  
  270.     return;
  271.  
  272.  
  273. # ...................................................................
  274. damaged:
  275.  
  276.     t_sender = GetSenderRef();
  277.     if ( t_sender == t_boss )
  278.     {
  279.         ReturnEx(0);
  280.     }
  281.  
  282.     return;
  283.  
  284.  
  285. # ...................................................................
  286. # Put boss into 'angry mode'
  287. # ...................................................................
  288. user0:
  289.  
  290.     AISetClass(t_boss, ai_mad);
  291.     n_MaxLavaShot = 6;
  292.  
  293.     return;
  294.  
  295.  
  296. # ...................................................................
  297. # Indicate next boss position
  298. # ...................................................................
  299. user1:
  300.  
  301.     t_posGhost = GetParam(0);
  302.     if ( t_posGhost > -1 )
  303.     {
  304. #        DEBUGPRINT("Setting new boss pos");
  305.         if ( GetThingType(t_posGhost) != 8 )
  306.         {
  307. #            DEBUGPRINT("Invalid GHOST object sent as boss pos");
  308.             t_posGhost = -1;
  309.         }
  310.     }
  311.  
  312.     return;
  313.  
  314.  
  315. # ===================================================================
  316. #    Subroutines
  317. # ===================================================================
  318.  
  319. # ...................................................................
  320. ShootLavaPlume:
  321.  
  322.     if ( t_posGhost == -1 )
  323.         return;
  324.  
  325.     vec_pos = VectorAdd(GetThingPos(t_posGhost), '0 0 0.005');
  326.  
  327.     vec_dir = VectorSet(0, 0.15, 0);
  328.     for (n_idx = 0; n_idx < 8; n_idx = n_idx + 1)
  329.     {
  330.         vec_dir    = VectorRotate(vec_dir, '0 45 0');
  331.         vec_rot    = VectorAdd(vec_pos, vec_dir);
  332.         CreateThingAtPos(tpl_plume, FindNewSectorFromThing(t_boss, vec_rot), vec_rot, '0 0 0');
  333.     }
  334.  
  335.     return;
  336.  
  337.  
  338. # ...................................................................
  339. ShootLavaDebris:
  340.  
  341.     if ( t_posGhost == -1 )
  342.         return;
  343.  
  344.     vec_pos            = VectorAdd(GetThingPos(t_posGhost), '0 0 0.005');
  345.     sec_atNewPos    = FindNewSectorFromThing(t_posGhost, vec_pos);
  346.  
  347.     n_param = 50;
  348.     for (n_idx = 0; n_idx < n_param; n_idx = n_idx + 1)
  349.     {
  350.         vec_rot = VectorSet(RandBetween(0, 60), RandBetween(0, 359), 0);
  351.         vec_dir    = VectorRotate('0.0 0.75 0.55', vec_rot);
  352.         vec_dir = VectorScale(vec_dir, 0.6 + Rand());
  353.  
  354.         t_obj = CreateThingAtPos(tpl_lavaShrp0[RandBetween(0, 2)], sec_atNewPos, vec_pos, '0 0 0');
  355.         if ( t_obj > -1 )
  356.         {
  357.             SetLifeLeft(t_obj, 1.5);
  358.             SetThingVel(t_obj, vec_dir);
  359.  
  360.             SetThingMaxAngVel(t_obj, 800);
  361.             SetThingRotVel(t_obj, '800 0 0');
  362.  
  363.             t_objSpark = CreateThing(tpl_sparks00, t_obj);
  364.             if ( t_objSpark > -1 )
  365.             {
  366.                 AttachThingToThingEx(t_objSpark, t_obj, 0x08);
  367.             }
  368.         }
  369.     }
  370.  
  371.     return;
  372.  
  373.  
  374. # ...................................................................
  375. ShootLavaGuys:
  376.     t_player = GetLocalPlayerThing();
  377.     if (t_player < 0) return;
  378.  
  379.     n_AICustomMode = BITSET(n_AICustomMode, FIRING_LAVA);
  380.     Reset();
  381.  
  382. #    DEBUGPRINT("Attempting to shoot lava guys");
  383.     n_shotCount = 0;
  384.  
  385.     while ( (n_shotCount < n_MaxLavaShot) && (n_NumLavaGuys < 12) )
  386.     {
  387.         if ( BITTEST(GetActorFlags(t_boss), 0xC00) )                        # Bail if DEAF and BLIND
  388.         {
  389.             n_AICustomMode = BITCLEAR(n_AICustomMode, FIRING_LAVA);    
  390.             return;
  391.         }
  392.  
  393.         n_NumLavaGuys    = n_NumLavaGuys + 1;
  394.         n_shotCount        = n_shotCount + 1;
  395.  
  396.         vec_pos            = VectorAdd( GetThingPos(t_boss), VectorTransformToOrient(t_boss, vec_altOffset) );
  397.         sec_atNewPos    = FindNewSectorFromThing(t_boss, vec_pos);
  398.         t_LavaGuy        = CreateThingAtPos(tpl_LavaGuy, sec_atNewPos, vec_pos, '0 0 0');
  399.  
  400.         if ( t_LavaGuy > -1 )
  401.         {
  402.             PlaySoundClass(t_boss, 106);                                    # play 'fire1'
  403.             CreateThingAtPos(tpl_sparks01, sec_atNewPos, vec_pos, '0 0 0');
  404.  
  405.             CaptureThing(t_LavaGuy);
  406.             AISetCutsceneMode(t_LavaGuy);
  407.  
  408.             vec_dir        = VectorSub(GetThingPos(t_Player), GetThingPos(t_boss));
  409.             f_val        = VectorLen(vec_dir) + 0.3;
  410.  
  411. #            DEBUGFLEX(f_val, "Lava guy shot scale =");
  412.             if ( f_val > 1.7 )
  413.             {
  414.                 f_val = f_val * (1.7/f_val);
  415.             }
  416.  
  417.             vec_vel        = VectorScale(vec_dir, f_val);
  418.             vec_vel        = VectorSet(VectorX(vec_vel), VectorY(vec_vel), 0.40);
  419.  
  420.             vec_rot        = VectorSet(0, RandBetween(-10, 10), 0);
  421.  
  422.             SetThingVel(t_LavaGuy, VectorRotate(vec_vel, vec_rot));
  423.             SetThingTimer(t_LavaGuy, 1.5);
  424.         }
  425.  
  426.         Sleep(3.5 / n_MaxLavaShot);
  427.     }
  428.  
  429.     n_AICustomMode = BITCLEAR(n_AICustomMode, FIRING_LAVA);    
  430.     return;
  431.  
  432. end
  433.  
  434.